<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>莫伊の测试笔记</title><meta name="author" content="莫伊"><meta name="copyright" content="莫伊"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="幸运交给锦鲤，你只管努力就好">
<meta property="og:type" content="website">
<meta property="og:title" content="莫伊の测试笔记">
<meta property="og:url" content="https://mooii.gitee.io/index.html">
<meta property="og:site_name" content="莫伊の测试笔记">
<meta property="og:description" content="幸运交给锦鲤，你只管努力就好">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://portrait.gitee.com/uploads/avatars/user/1627/4881517_lolien_1621782146.png!avatar100">
<meta property="article:author" content="莫伊">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://portrait.gitee.com/uploads/avatars/user/1627/4881517_lolien_1621782146.png!avatar100"><link rel="shortcut icon" href="https://mooii.oss-cn-shanghai.aliyuncs.com/%E3%83%AA%E3%82%B9%E3%81%AE%E3%82%A2%E3%82%A4%E3%82%B3%E3%83%B3%E3%81%A7%E3%81%99%E3%81%9F%E3%81%84%E3%80%82.png"><link rel="canonical" href="https://mooii.gitee.io/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '莫伊の测试笔记',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2022-05-26 16:00:46'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper/swiper/swiper.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper/swiper/swiperstyle.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/hexo-electric-clock@1.0.6/clock.css"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-clock/lib/clock.min.css" /><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-butterfly-tag-plugins-plus@latest/lib/tag_plugins.min.css" media="defer" onload="this.media='all'"><script async src="https://cdn.jsdelivr.net/npm/hexo-butterfly-tag-plugins-plus@latest/lib/carousel-touch.min.js"></script><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://portrait.gitee.com/uploads/avatars/user/1627/4881517_lolien_1621782146.png!avatar100" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">35</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fa fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('https://mooii.oss-cn-shanghai.aliyuncs.com/20211021164956.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">莫伊の测试笔记</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fa fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">莫伊の测试笔记</h1><div id="site-subtitle"><span id="subtitle"></span></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="recent-post-content left"><a class="article-content" href="/2022/05/25/python06/"><div class="article-content-text">输入与输出基础键盘输入输出最简单的例子：input和print12345## 输入name = input(&#x27;please input your name:&#x27;)# 输出print(&#x27;hello world!!!&#x27;)🐶ATTENTION：

input()函数暂停程序运行，同时等待键盘输入，直到回车被按下，输入的类型为字符串型（str）
print()函数接受字符串、数字、字典、列表以及一些自定义类的输出

文件输入输出伪代码实现：
1.读取文件
2.去除所有标点符号和换行符，并把所有大写变成小写
3.合并相同的词，统计每个词出现的频率，并按照词频从大到小排序
4.将结果输出到文件out.txt
</div></a><div class="recent-post-info"><a class="article-title" href="/2022/05/25/python06/"><div class="article-title-link">python06-输入与输出</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2022-05-25T14:40:00.000Z" title="发表于 2022-05-25 22:40:00">2022-05-25</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Python/">Python</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5373(20211213-233042).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><a class="article-content" href="/2022/05/25/python05/"><div class="article-content-text">概念
字典dict：由一系列键（key）和值（value）配对组成的元素的集合
集合set：没有键和值的配对，是一系列无序的、唯一的元素组合创建方式

123456d1 = &#123;&#x27;name&#x27;: &#x27;jason&#x27;, &#x27;age&#x27;: 20, &#x27;gender&#x27;: &#x27;male&#x27;&#125;d2 = dict(&#123;&#x27;name&#x27;: &#x27;jason&#x27;, &#x27;age&#x27;: 20, &#x27;gender&#x27;: &#x27;male&#x27;&#125;)d3 = dict([(&#x27;name&#x27;, &#x27;jason&#x27;), (&#x27;age&#x27;, 20), (&#x27;gender&#x27;, &#x27;male&#x27;)])d4 = dict(name=&#x27;jason&#x27;, age=20, gender=&#x27;male&#x27;) d1 == d2 = ...</div></a><div class="recent-post-info"><a class="article-title" href="/2022/05/25/python05/"><div class="article-title-link">python05-字典和集合</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2022-05-25T14:20:14.000Z" title="发表于 2022-05-25 22:20:14">2022-05-25</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Python/">Python</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5370(20211213-232951).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><a class="article-content" href="/2022/04/10/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%9501/"><div class="article-content-text">！！！首先明确一点，不管什么指标，在一个团队中，大家对于同一个指标的理解是一致的
TPS和并发数什么是并发可以参考下图：

在图中，并发数16TPS，就是1秒内系统处理了16个事务（不要纠结绝对并发还是相对并发）
也就是说并发数就是每秒钟系统处理的事务数量，而TPS是用来描述并发的概念，16TPS，就是一秒内系统处理了16个事务
在线用户数、并发用户数怎么计算还是通过一个简单的示意图：

从图里面可以看到，一共有32个用户进入了系统，但是绿色的用户并没有任何动作
所以在线用户数是32个，并发用户数是16个
但是通常情况下，为了能hold住更多的用户，我们通常都会把一些数据存放到redis这类的缓存服务器中，所以可以以缓存的内存大小来计算预估最大的在线用户数
但是并发用户数，需要在系统中执行某个动作
</div></a><div class="recent-post-info"><a class="article-title" href="/2022/04/10/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%9501/"><div class="article-title-link">性能测试01-性能测试中各种指标的关系</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2022-04-10T15:17:35.000Z" title="发表于 2022-04-10 23:17:35">2022-04-10</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95/">性能测试</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5371(20211213-233011).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><a class="article-content" href="/2022/01/09/python04/"><div class="article-content-text">前言文件读取是最常见的IO操作，python中内置了读写文件的函数
文件读取可使用python内置的open()函数，传入文件名以及标示符
伪代码如下
123用open打开文件打开文件成功，调用read()方法可以一次性读取文件的全部内容调用close方法，关闭文件
代码实现：
1234filepath = &#x27;./test.txt&#x27;f = open(filepath,&#x27;r&#x27;,encoding=&#x27;utf-8&#x27;)print(f.read())f.close()
打印结果如下：
12345这就是一个测试文件嘻嘻嘻哈哈哈testemmm
查看open()的源码可知完整的语法格式
1open(file, mode=&#x27;r&#x27;, buffering=None, encoding=None, errors=None, newline=None, closefd=True)
参数说明：
1234567- file：必须，表示文件路径- mode：可选，表示文件打开模式- buffering：设置缓冲- encoding：一般使 ...</div></a><div class="recent-post-info"><a class="article-title" href="/2022/01/09/python04/"><div class="article-title-link">python04-文件读取</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2022-01-09T15:03:14.000Z" title="发表于 2022-01-09 23:03:14">2022-01-09</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Python/">Python</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5371(20211213-233011).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><a class="article-content" href="/2022/01/09/python03/"><div class="article-content-text">str.split()作用：通过指定分隔符对字符串进行切片（分割成列表）如果参数 num 有指定值，则分隔 num+1 个子字符串
语法：
1str.split(str=&quot;&quot;, num=string.count(str))
用法
1234str = &quot;hello world !!!&quot;print(str.split())print(str.split(&quot; &quot;,1))
执行结果
12[&#x27;hello&#x27;, &#x27;world&#x27;, &#x27;!!!&#x27;][&#x27;hello&#x27;, &#x27;world !!!&#x27;]
str.join()作用：将序列中的元素以指定字符连接成一个新的字符串
语法
1str.join(sequence)
用法
123str = &quot;-&quot;;seq = (&quot;a&quot;, &quot;b&quot;, &quot;c&quot;); # 字符串序列print str.join(seq);
执行结果
1a-b-c
！！！ ...</div></a><div class="recent-post-info"><a class="article-title" href="/2022/01/09/python03/"><div class="article-title-link">python03-字符串常用函数</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2022-01-09T15:02:17.000Z" title="发表于 2022-01-09 23:02:17">2022-01-09</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Python/">Python</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5374(20211213-233104).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><a class="article-content" href="/2022/01/09/python02/"><div class="article-content-text">列表和元组基础什么是列表和元组
都是一个可以方式任意数据类型的有序集合

对于python而言，集合中的数据类型可以不一致，如下：
12345# 列表中同时含有int和string类型的元素list1 = [1,2,&#x27;hello&#x27;,&#x27;world&#x27;]# 元组中同时含有int和string类型的元素tup = (&#x27;jason&#x27;, 22) 
列表和元组的区别
列表是动态的：长度大小不固定，可以随意增加、删减或者改变元素（mutable）
元组是静态的：长度大小固定，无法增加删减或者改变（immutable）

即列表是可变的，元组是不可变的


举个栗子
12345678910111213l = [1, 2, 3, 4]# 和很多语言类似，python中索引同样从0开始，l[3]表示访问列表的第四个元素l[3] = 40 print(l)# 打印结果如下[1, 2, 3, 40]tup = (1, 2, 3, 4)tup[3] = 40# 控制台报错信息Traceback (most recent call last):  File ...</div></a><div class="recent-post-info"><a class="article-title" href="/2022/01/09/python02/"><div class="article-title-link">python02-列表和元组</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2022-01-09T14:44:20.000Z" title="发表于 2022-01-09 22:44:20">2022-01-09</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Python/">Python</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5373(20211213-233042).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><a class="article-content" href="/2022/01/09/python01/"><div class="article-content-text">
什么是字符串字符串：是由独立字符组成的一个序列，通常包含在单引号&#39;&#39;、双引号&quot;&quot;、或者三引号之中&#39;&#39;&#39; &#39;&#39;&#39;或者&quot;&quot;&quot; &quot;&quot;&quot;
定义字符串
123name = &#x27;mooii&#x27;city = &#x27;shanghai&#x27;text = &#x27;hello world!&#x27;
在python中三引号&quot;&quot;&quot; &quot;&quot;&quot;多用于函数的注释
转义字符含义：用反斜杠\开头的字符串
作用：用来表示一些特定意义的字符
常见的转义字符：
| 转义字符 | 说明          || ———— | ——————- || \newline | 接下一行      || \       | 表示\         || \’       | 表示单引号&#39; || \”       | 表示双引号&quot; || \n       | 换行          ||  ...</div></a><div class="recent-post-info"><a class="article-title" href="/2022/01/09/python01/"><div class="article-title-link">python01-字符串</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2022-01-09T14:42:42.000Z" title="发表于 2022-01-09 22:42:42">2022-01-09</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Python/">Python</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5374(20211213-233104).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><a class="article-content" href="/2021/12/18/selenium08/"><div class="article-content-text">什么是cookies
网站为了辨别用户身份、进行 session 跟踪而储存在用户本地终端上的数据(通常是加密的)

使用步骤伪代码实现如下：

获取cookiesget_cookies()
再通过add_cookies()使用

还是以企业微信为例，首先通过浏览器复用获取企业微信登录的cookies1cookies = driver.get_cookies()
再通过add_cookies()使用cookies进行登录
12345678910111213def test_cookies(self):    driver = webdriver.Chrome()    # 进入企业微信登录页    driver.get(&quot;https://work.weixin.qq.com/&quot;)    # 使用cookies登录    cookies = [your_cookies]    for cookie in cookies:        driver.add_cookie(cookie)    # 进入我的企业页面    driver.get(&quot;https:/ ...</div></a><div class="recent-post-info"><a class="article-title" href="/2021/12/18/selenium08/"><div class="article-title-link">selenium系列08-使用cookies绕过登录</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-12-18T15:23:14.000Z" title="发表于 2021-12-18 23:23:14">2021-12-18</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Selenium/">Selenium</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5370(20211213-232951).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content left"><a class="article-content" href="/2021/12/17/selenium07/"><div class="article-content-text">说明：本文转载自小菠萝的测试笔记
前言
在UI自动化测试中，PO是目前最为主流，也是公认最佳的设计模式
UI自动化测试最初是通过关键字驱动+数据驱动的形式来实现，然后升级到PO模式

什么是关键字驱动
简单而言，就是将Selenium常用功能进行二次封装
譬如：把查找元素、点击、输入等原生方法进行封装

特点：可以让不懂代码的测试人员也能做自动化测试，彻底地实现测试步骤、测试数据和程序的分离


关键字驱动 vs RF
可以把关键字驱动对比用RF（Robot Framework）做的自动化测试，在RF GUI界面调用关键字，并传入参数即可完成一系列的元素操作；
而我们在Pycharm上完成关键字驱动也是相同道理，封装好Selenium常用方法，然后去调用关键字，不同页面传入不同的参数即可完成一系列的元素操作

什么是数据驱动
固定的程序，固定的测试步骤，使用不同的数据进行测试【需要多组数据来测试】
将代码和数据进行分离，单纯由数据组成文件，再由文件来驱动关键字，最终实现整个自动化的流程

什么是关键字驱动+数据驱动
读取数据，将固定格式的数据进行拼接【读取数据】
拼接后的内容作为关键字 ...</div></a><div class="recent-post-info"><a class="article-title" href="/2021/12/17/selenium07/"><div class="article-title-link">selenium系列07-PO处理模式</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-12-17T15:23:14.000Z" title="发表于 2021-12-17 23:23:14">2021-12-17</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Selenium/">Selenium</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5375(20211213-233124).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><div class="recent-post-item"><div class="recent-post-content right"><a class="article-content" href="/2021/12/16/selenium05/"><div class="article-content-text">
使用js的好处


解决大部分click()不生效的问题
页面滚动到底部，顶部
处理富文本、时间控件的输入


调用js方式 execute_script()

12# 执行jsdriver.execute_script(&quot;js语句&quot;)
滑动至页面底部举个栗子：滑动百度搜索页至页面底部
1driver.execute_script(&quot;document.documentElement.scrollTop=100000&quot;)
元素点击123# js中加入return 可返回元素element = driver.execute_script(&quot;return document.getElementById(&#x27;su&#x27;)&quot;)element.click()
🎉ATTENTION：

js语句中加入return，可返回对应元素
js语句中可添加多个js语句，用分号隔开，多个js语句会依次执行

处理时间控件前置条件：

大部分时间控件都是readonly属性，需要手动去选择相应时间，自动化测试中对事件控件的操作可以使用j ...</div></a><div class="recent-post-info"><a class="article-title" href="/2021/12/16/selenium05/"><div class="article-title-link">selenium系列05-js处理方式</div></a><div class="recent-post-meta">               <div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2021-12-16T15:23:14.000Z" title="发表于 2021-12-16 23:23:14">2021-12-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/Selenium/">Selenium</a></span></div></div></div><div class="recent-post-cover"><img class="article-cover" src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5375(20211213-233124).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'"></div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span><a class="page-number" href="/page/2/#content-inner">2</a><span class="space">&hellip;</span><a class="page-number" href="/page/4/#content-inner">4</a><a class="extend next" rel="next" href="/page/2/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://portrait.gitee.com/uploads/avatars/user/1627/4881517_lolien_1621782146.png!avatar100" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">莫伊</div><div class="author-info__description">幸运交给锦鲤，你只管努力就好</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">35</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/mooii"><i class="https://mooii.oss-cn-shanghai.aliyuncs.com/20211021164956.png"></i><span>我的主页</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">人生有限，接受事与愿违！！！</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/05/25/python06/" title="python06-输入与输出"><img src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5373(20211213-233042).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="python06-输入与输出"/></a><div class="content"><a class="title" href="/2022/05/25/python06/" title="python06-输入与输出">python06-输入与输出</a><time datetime="2022-05-25T14:40:00.000Z" title="发表于 2022-05-25 22:40:00">2022-05-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/05/25/python05/" title="python05-字典和集合"><img src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5370(20211213-232951).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="python05-字典和集合"/></a><div class="content"><a class="title" href="/2022/05/25/python05/" title="python05-字典和集合">python05-字典和集合</a><time datetime="2022-05-25T14:20:14.000Z" title="发表于 2022-05-25 22:20:14">2022-05-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/04/10/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%9501/" title="性能测试01-性能测试中各种指标的关系"><img src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5371(20211213-233011).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="性能测试01-性能测试中各种指标的关系"/></a><div class="content"><a class="title" href="/2022/04/10/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%9501/" title="性能测试01-性能测试中各种指标的关系">性能测试01-性能测试中各种指标的关系</a><time datetime="2022-04-10T15:17:35.000Z" title="发表于 2022-04-10 23:17:35">2022-04-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/01/09/python04/" title="python04-文件读取"><img src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5371(20211213-233011).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="python04-文件读取"/></a><div class="content"><a class="title" href="/2022/01/09/python04/" title="python04-文件读取">python04-文件读取</a><time datetime="2022-01-09T15:03:14.000Z" title="发表于 2022-01-09 23:03:14">2022-01-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/01/09/python03/" title="python03-字符串常用函数"><img src="https://mooii.oss-cn-shanghai.aliyuncs.com/IMG_5374(20211213-233104).PNG" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="python03-字符串常用函数"/></a><div class="content"><a class="title" href="/2022/01/09/python03/" title="python03-字符串常用函数">python03-字符串常用函数</a><time datetime="2022-01-09T15:02:17.000Z" title="发表于 2022-01-09 23:02:17">2022-01-09</time></div></div></div></div><div class="card-widget" id="card-newest-comments"><div class="item-headline"><i class="fas fa-comment-dots"></i><span>最新评论</span></div><div class="aside-list"><span>正在加载中...</span></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Pytest/"><span class="card-category-list-name">Pytest</span><span class="card-category-list-count">20</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Python/"><span class="card-category-list-name">Python</span><span class="card-category-list-count">6</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/Selenium/"><span class="card-category-list-name">Selenium</span><span class="card-category-list-count">8</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/categories/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95/"><span class="card-category-list-name">性能测试</span><span class="card-category-list-count">1</span></a></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/tags/Pytest/" style="font-size: 1.5em; color: #99a9bf">Pytest</a> <a href="/tags/Python/" style="font-size: 1.23em; color: #999ea6">Python</a> <a href="/tags/Selenium/" style="font-size: 1.37em; color: #99a4b2">Selenium</a> <a href="/tags/UI%E8%87%AA%E5%8A%A8%E5%8C%96/" style="font-size: 1.37em; color: #99a4b2">UI自动化</a> <a href="/tags/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95/" style="font-size: 1.1em; color: #999">性能测试</a> <a href="/tags/%E6%B5%8B%E8%AF%95%E6%A1%86%E6%9E%B6/" style="font-size: 1.5em; color: #99a9bf">测试框架</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/05/"><span class="card-archive-list-date">五月 2022</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/04/"><span class="card-archive-list-date">四月 2022</span><span class="card-archive-list-count">1</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2022/01/"><span class="card-archive-list-date">一月 2022</span><span class="card-archive-list-count">4</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/12/"><span class="card-archive-list-date">十二月 2021</span><span class="card-archive-list-count">14</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/11/"><span class="card-archive-list-date">十一月 2021</span><span class="card-archive-list-count">13</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/archives/2021/10/"><span class="card-archive-list-date">十月 2021</span><span class="card-archive-list-count">1</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">35</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2021-11-17T16:00:00.000Z"></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2022-05-26T08:00:45.808Z"></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2021 - 2022 By 莫伊</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">好好学习🧡天天学习</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><div class="js-pjax"><script>function subtitleType () {
  getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js').then(() => {
    jinrishici.load(function (result) {
      if (true) {
        var sub = "".length == 0 ? new Array() : "".split(',')
        var content = result.data.content
        var both = sub.unshift(content)
        var typed = new Typed('#subtitle', {
          strings: sub,
          startDelay: 300,
          typeSpeed: 150,
          loop: true,
          backSpeed: 50,
        })
      } else {
        document.getElementById('subtitle').innerHTML = result.data.content
      }
    })
  })
}

if (true) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}
</script></div><script data-pjax defer src="/js/custom/fixed_card_widget.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><div id="fixedcard-dashboard"><button class="fixedcard-activebtn" type="button" title="用户信息" onclick="FixedCardWidget(&quot;class&quot;,&quot;card-info&quot;,&quot;0&quot;)"><i class="fas fa-address-book"></i></button><button class="fixedcard-activebtn" type="button" title="电子钟" onclick="FixedCardWidget(&quot;class&quot;,&quot;card-clock&quot;,&quot;0&quot;)"><i class="fas fa-cloud-sun"></i></button><button class="fixedcard-activebtn" type="button" title="碎碎念" onclick="FixedCardWidget(&quot;class&quot;,&quot;card-shuo&quot;,&quot;0&quot;)"><i class="fas fa-comments"></i></button><button class="fixedcard-activebtn" type="button" title="最新文章" onclick="FixedCardWidget(&quot;class&quot;,&quot;card-recent-post&quot;,&quot;0&quot;)"><i class="fas fa-history"></i></button><button class="fixedcard-activebtn" type="button" title="最新评论" onclick="FixedCardWidget(&quot;id&quot;,&quot;card-newest-comments&quot;,&quot;0&quot;)"><i class="fas fa-comment-dots"></i></button><button class="fixedcard-activebtn" type="button" title="标签" onclick="FixedCardWidget(&quot;class&quot;,&quot;card-tags&quot;,&quot;0&quot;)"><i class="fas fa-tags"></i></button><button class="fixedcard-activebtn" type="button" title="网站咨询" onclick="FixedCardWidget(&quot;class&quot;,&quot;card-webinfo&quot;,&quot;0&quot;)"><i class="fas fa-chart-line"></i></button><div class="fixedcard-user-avatar fixedcard-activebtn" onclick="RemoveFixedCardWidget()"><img class="fixedcard-user-avatar-img" src="https://portrait.gitee.com/uploads/avatars/user/1627/4881517_lolien_1621782146.png!avatar100" title="莫伊"></div></div></div><!-- hexo injector body_end start --> <script data-pjax>if(document.getElementById('recent-posts') && location.pathname =='/'){
    
    var parent = document.getElementById('recent-posts');
    var child = '<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms"></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>';
    console.log('已挂载swiper')
    parent.insertAdjacentHTML("afterbegin",child)}
     </script>
<script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper/swiper/swiper.min.js"></script>
<script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-swiper@0.18/swiper/swiperindex.js"></script>
<style></style><script data-pjax>function electric_clock_injector_config(){
                var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
                var item_html = 'undefined';
                console.log('已挂载electric_clock')
                // parent_div_git.innerHTML=item_html+parent_div_git.innerHTML // 无报错，但不影响使用(支持pjax跳转)
                parent_div_git.insertAdjacentHTML("afterbegin",item_html) // 有报错，但不影响使用(支持pjax跳转)
            }if( document.getElementsByClassName('sticky_layout')[0] && (location.pathname ==='all'|| 'all' ==='all')){

            electric_clock_injector_config()
        } </script><script src="https://pv.sohu.com/cityjson?ie=utf-8"></script><script data-pjax  src="https://cdn.jsdelivr.net/gh/Zfour/hexo-electric-clock@1.0.6/clock.js"></script><script data-pjax>
  function butterfly_clock_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src="https://npm.elemecdn.com/hexo-butterfly-clock/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_injector_config();
  }
  </script><script src="https://pv.sohu.com/cityjson?ie=utf-8"></script><script data-pjax src="https://npm.elemecdn.com/hexo-butterfly-clock/lib/clock.min.js"></script><script async src="//at.alicdn.com/t/font_2032782_8d5kxvn09md.js"></script><!-- hexo injector body_end end --></body></html>